package com.fenghongzhang.one;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;

public class Table2Provider extends ContentProvider {
    private SQLiteDatabase db;
    public Table2Provider() {
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        // Implement this to handle requests to delete one or more rows.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public String getType(Uri uri) {
        // TODO: Implement this to handle requests for the MIME type of the data
        // at the given URI.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public Uri insert(Uri uri, ContentValues values) {
        // TODO: Implement this to handle requests to insert a new row.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    /**
     * 是不是就是操作自己的数据库的表的方法.
     * @return
     */
    @Override
    public boolean onCreate() {
        MySqlHelp mySqlHelp = new MySqlHelp(getContext(), "tabletest.db", null, 1);
         db = mySqlHelp.getReadableDatabase();
         if(db != null){
             return true;
         }
        return false;
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        Cursor table2 = db.query("table2", projection, selection, selectionArgs, null, null, sortOrder);
        return table2;
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection,
                      String[] selectionArgs) {
        // TODO: Implement this to handle requests to update one or more rows.
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
